﻿<UserControl x:Class="LocultApp.Views.Pages.SettingsPages.GeneralSettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="600"
             
             xmlns:conv="clr-namespace:LocultApp.Converter"
             xmlns:local="clr-namespace:LocultApp.Local"
             xmlns:behav="clr-namespace:LocultApp.Behaviours"
             xmlns:dropbrowser="clr-namespace:DropDownButtonLib.Controls;assembly=DropDownButtonLib"
             xmlns:views="clr-namespace:LocultApp.Views.Pages.SettingsPages"
    >
    <Grid>
        <Grid.Resources>
            <conv:BoolToVisibilityConverter FalseValue="Hidden" TrueValue="Visible" x:Key="BoolToVis" />
            <conv:BoolToVisibilityConverter FalseValue="Visible" TrueValue="Hidden" x:Key="InverseBoolToVis" />
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="2*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"  Margin="3">
            <CheckBox IsChecked="{Binding ReloadFilesOnAppStart}"
                              Content="{x:Static local:Strings.STR_ReloadFilesOnStartUp_CAPTION}" Margin="9"/>

            <StackPanel Margin="6,9">
                <Label Content="{x:Static local:Strings.STR_CURRENT_APP_LANG_CAPTION}"
                           ToolTip="{x:Static local:Strings.STR_CURRENT_APP_LANG_CAPTION_TT}"
                           ContentStringFormat="{}{0}:"
                           Target="{Binding ElementName=CMB_ApplicationLanguage}"
                           Margin="0,3,3,0"
                           />
                <ComboBox ItemsSource="{Binding Languages}"
                              SelectedItem="{Binding LanguageSelected}"
                              SelectedValuePath="BCP47"
                              DisplayMemberPath="DisplayName"
                              HorizontalAlignment="Left" VerticalAlignment="Top"
                              MinWidth="150" Margin="3,0,3,3"
                              ToolTip="{x:Static local:Strings.STR_CURRENT_APP_LANG_CAPTION_TT}"
                              Name="CMB_ApplicationLanguage"
                              />
            </StackPanel>
            <StackPanel Margin="6,9" Visibility="{Binding IsIconSizeEditVisible, Converter={StaticResource BoolToVis}}" >
                <Label Content="{x:Static local:Strings.STR_ICON_SIZE_LABEL}"
                           ToolTip="{x:Static local:Strings.STR_ICON_SIZE_LABEL_TT}"
                           ContentStringFormat="{}{0}:"
                           Target="{Binding ElementName=sldIconSize}"
                           Margin="0,3,3,0"
                           />
                <Slider Name="sldIconSize"
                        Value="{Binding IconSize}"
                        Minimum="{Binding IconSizeMin}"
                        Maximum="{Binding IconSizeMax}"
                        />
                <TextBlock Text="{Binding IconSize , UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>
        </StackPanel>

        <GroupBox Grid.Column="1" Grid.Row="0"
                      Header="{x:Static local:Strings.STR_MS_Translate_Caption}" VerticalAlignment="Top">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!-- Uri -->
                <Grid Grid.Column="0" Grid.Row="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Label  Grid.Row="0"
                                Content="{x:Static local:Strings.STR_MS_TRANSLATE_URI_CAPTION}"
                                ContentStringFormat="{}{0}:"
                                Margin="0,3,3,0" Target="{Binding ElementName=UriTextBox}" />
                    <TextBox Grid.Row="1" Name="UriTextBox"
                             Text="{Binding TranslationServiceUri, UpdateSourceTrigger=PropertyChanged}"
                             Margin="3,0,3,3" />
                </Grid>

                <!-- User Name -->
                <Grid Grid.Column="0" Grid.Row="1" Margin="9,0,3,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Label  Grid.Row="0" Grid.Column="0"
                            Content="{x:Static local:Strings.STR_MS_TRANSLATE_USER_CAPTION}"
                            ContentStringFormat="{}{0}:"
                            Margin="0,3,3,0" Target="{Binding ElementName=UserTextBox}" VerticalAlignment="Bottom"/>
                    <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Name="UserTextBox" Margin="0">
                        <PasswordBox Margin="0,0,3,0" 
                                     behav:PasswordBoxTextChanged.EncryptedPassword="{Binding TranslationServiceUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         />
                    </Grid>
                </Grid>

                <!-- Password -->
                <Grid Grid.Column="0" Grid.Row="3" Margin="9,3,3,3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Label  Grid.Row="0" Grid.Column="0"
                                Content="{x:Static local:Strings.STR_MS_TRANSLATE_PASSWD_CAPTION}"
                                ContentStringFormat="{}{0}:"
                                Margin="0,3,3,0" Target="{Binding ElementName=PasswortTextBox}" VerticalAlignment="Bottom"/>
                    <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Name="PasswortTextBox" Margin="0">

                        <PasswordBox Margin="0,0,3,0" 
                         behav:PasswordBoxTextChanged.EncryptedPassword="{Binding TranslationServicePassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         />

                    </Grid>
                </Grid>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Column="1" Grid.Row="1"
                      Header="{x:Static local:Strings.STR_NewDefaultSolutionOptions_Caption}">
            <Grid HorizontalAlignment="Left">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0">
                    <Label Content="{x:Static local:Strings.STR_DefaultSourceLanguage_CAPTION}"
                           ToolTip="{x:Static local:Strings.STR_DefaultSourceLanguage_CAPTION_TT}"
                           ContentStringFormat="{}{0}:"
                           Target="{Binding ElementName=CMB_DefaultSourceLanguage}"
                           Margin="0,3,3,0"
                           />
                    <ComboBox ItemsSource="{Binding DefaultLanguages}"
                              SelectedItem="{Binding DefaultSourceLanguageSelected}"
                              SelectedValuePath="Bcp47_LangCode"
                              HorizontalAlignment="Left" VerticalAlignment="Top"
                              MinWidth="150" Margin="3,0,3,3"
                              ToolTip="{x:Static local:Strings.STR_DefaultSourceLanguage_CAPTION_TT}"
                              Name="CMB_DefaultSourceLanguage"
                              ItemTemplate="{StaticResource LanguageDataTemplate}"
                              />
                </StackPanel>

                <TextBlock FontSize="24" Text="->" Grid.Column="1" Margin="9,3" />

                <StackPanel Grid.Column="2">
                    <Label Content="{x:Static local:Strings.STR_DefaultTargetLanguage_CAPTION}"
                           ToolTip="{x:Static local:Strings.STR_DefaultTargetLanguage_CAPTION_TT}"
                           ContentStringFormat="{}{0}:"
                           Target="{Binding ElementName=CMB_DefaultTargetLanguage}"
                           Margin="0,3,3,0"
                           />
                    <ComboBox ItemsSource="{Binding DefaultLanguages}"
                              SelectedItem="{Binding DefaultTargetLanguageSelected}"
                              SelectedValuePath="Bcp47_LangCode"
                              HorizontalAlignment="Left" VerticalAlignment="Top"
                              MinWidth="150" Margin="3,0,3,3"
                              ToolTip="{x:Static local:Strings.STR_DefaultTargetLanguage_CAPTION_TT}"
                              Name="CMB_DefaultTargetLanguage"
                              ItemTemplate="{StaticResource LanguageDataTemplate}"
                              />

                </StackPanel>
            </Grid>
        </GroupBox>

        <!-- View for editing bookmarks -->
        <GroupBox Header="{x:Static local:Strings.STR_BOOKMARKS_OPTION_CAPTION}"
                  ToolTip="{x:Static local:Strings.STR_BOOKMARKS_OPTION_CAPTION_TT}"
                  Grid.Column="1" Grid.Row="2">
            <views:EditBookmarksView Margin="6,9" DataContext="{Binding BookmarkedFolders}" />
        </GroupBox>
    </Grid>
</UserControl>
